﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SmartMD.Manager.Report
{
    public class CharUtil
    {
        public static string GetExcelCharByNumber(int n)
        {
            string str = "";
            do
            {
                str = GetCharByNumber(n % 26) + str;
                n = n / 26;
            }while(n > 0);
            return str;
        }

        public static string GetCharByNumber(int n)
        {
            string ch = "";
            switch(n)
            {
                case 1:
                    ch = "A";
                    break;
                case 2:
                    ch = "B";
                    break;
                case 3:
                    ch = "C";
                    break;
                case 4:
                    ch = "D";
                    break;
                case 5:
                    ch = "E";
                    break;
                case 6:
                    ch = "F";
                    break;
                case 7:
                    ch = "G";
                    break;
                case 8:
                    ch = "H";
                    break;
                case 9:
                    ch = "I";
                    break;
                case 10:
                    ch = "J";
                    break;
                case 11:
                    ch = "K";
                    break;
                case 12:
                    ch = "L";
                    break;
                case 13:
                    ch = "M";
                    break;
                case 14:
                    ch = "N";
                    break;
                case 15:
                    ch = "O";
                    break;
                case 16:
                    ch = "P";
                    break;
                case 17:
                    ch = "Q";
                    break;
                case 18:
                    ch = "R";
                    break;
                case 19:
                    ch = "S";
                    break;
                case 20:
                    ch = "T";
                    break;
                case 21:
                    ch = "U";
                    break;
                case 22:
                    ch = "V";
                    break;
                case 23:
                    ch = "W";
                    break;
                case 24:
                    ch = "X";
                    break;
                case 25:
                    ch = "Y";
                    break;
                case 26:
                    ch = "Z";
                    break;
            }
            return ch;
        }
    }
}
